package com.googlecode.cgpwall;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.provider.BaseColumns;
import android.util.Log;

public class EventDataSQLHelper extends SQLiteOpenHelper {
	private static final String DATABASE_NAME = "cgpwall.db";
	private static final int DATABASE_VERSION = 1;

	// Table name
	public static final String TABLE = "wallpapers";
	public static final String SAVE_TABLE = "saves";

	// Columns

	
	public static final String NODE= "node";
	public static final String LASTSAVE= "lastsave";



	public EventDataSQLHelper(Context context) {
		super(context, DATABASE_NAME, null, DATABASE_VERSION);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		String sql = "create table " + TABLE + "( " + BaseColumns._ID
		+ " integer primary key autoincrement, "
		+ NODE + " text);";
		Log.d("Wallpaper", "onCreate: " + sql);
		db.execSQL(sql);
		sql = "create table " + SAVE_TABLE + "( " + BaseColumns._ID
		+ " integer primary key autoincrement, "
		+ LASTSAVE + " text);";
		Log.d("Wallpaper", "onCreate: " + sql);
		db.execSQL(sql);
		
		
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		if (oldVersion >= newVersion)
			return;

		db.execSQL("drop table if exists " + TABLE);
		db.execSQL("drop table if exists " + SAVE_TABLE);
		onCreate(db);
	}

}